/*
 * smtp.h
 *
 *  Created on: 12/giu/2014
 *      Author: kappa
 */

#ifndef SMTP_H_


#define SMTP_H_

#ifdef _WIN32
   /*definizioni x MS Windows*/
   #include <windows.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils/commons.h"



typedef enum CMD{
	NONE,
	HELO,
	MAIL,
	RCPT,
	DATA,
	QUIT,
	RSET,
	NOOP,
	HELP,
	TIMEOUT,
	USER,
	PASS,
	LIST,
	RETR,
	DELE,
	SEND,
	SOML,
	SAML,
	VRFY,
	EXPN,
	TURN,
	STAT,
	APOP,
	TOP,
	UIDL
}CMD;


typedef enum RESP_CODE{
	RESP_NULL = -1,
	RESP_214 = 214,
	RESP_220 = 220,
	RESP_221 = 221,
	RESP_250 = 250,
	RESP_354 = 354,
	RESP_421 = 421,
	RESP_422 = 422,
	RESP_451 = 451,
	RESP_452 = 452,
	RESP_500 = 500,
	RESP_501 = 501,
	RESP_502 = 502,
	RESP_503 = 503,
	RESP_523 = 523,
	RESP_550 = 550,
	RESP_551 = 551,
	RESP_552 = 552,
	RESP_553 = 553,




	RESP_POP3_SRV_OK = 14000,
	RESP_POP3_USR_OK,
	RESP_POP3_PASS_OK,
	RESP_POP3_NOOP,
	RESP_POP3_LIST_OK,
	RESP_POP3_LIST_ID_OK,
	RESP_POP3_RTR_OK,
	RESP_POP3_DELE_OK,
	RESP_POP3_QUIT,
	RESP_POP3_RSET,

//	RESP_POP3_ERR = 14001,
	RESP_POP3_USR_KO,
	RESP_POP3_PASS_KO_LCK,
	RESP_POP3_PASS_KO_WP,
	RESP_POP3_LIST_NO_ID,
	RESP_POP3_RTR_KO,
	RESP_POP3_STATUS_KO,
	RESP_POP3_DELE_KO,
	RESP_POP3_SYNTAX_KO
}RESPONSE;



#define RESP_214_MSG "%d I have to write a help text.\r\n"
#define RESP_220_MSG "%d %s Service ready\r\n" //<domain>
#define RESP_221_MSG "%d %s Service closing transmission channel\r\n" //<domain>
#define RESP_250_MSG "%d Requested mail action okay, completed\r\n"

#define RESP_354_MSG "%d Start mail input; end with <CRLF>.<CRLF>\r\n"

#define RESP_421_MSG "%d %s Service not available,closing transmission channel\r\n" //<domain>  //[This may be a reply to any command if the service knows it must shut down]
#define RESP_422_MSG "%d receiving mailbox full"
#define RESP_451_MSG "%d Requested action aborted: error in processing\r\n"
#define RESP_452_MSG "%d Requested action not taken: insufficient system storage\r\n"

#define RESP_500_MSG "%d Syntax error, command unrecognized\r\n" //[This may include errors such as command line too long]
#define RESP_501_MSG "%d Syntax error in parameters or arguments\r\n"
#define RESP_502_MSG "%d Command not implemented\r\n"
#define RESP_503_MSG "%d Bad sequence of commands\r\n"
#define RESP_523_MSG "%d Message too long\r\n"
#define RESP_550_MSG "%d Requested action not taken: mailbox unavailable\r\n" //[E.g., mailbox not found, no access]
#define RESP_551_MSG "%d User not local; please try %s\r\n"//<forward-path>
#define RESP_552_MSG "%d Requested mail action aborted: exceeded storage allocation\r\n"
#define RESP_553_MSG "%d Requested action not taken: mailbox name not allowed\r\n" //[E.g., mailbox syntax incorrect]

#define RESP_POP3_SRV_OK_MSG "POP3 server ready\r\n"
#define RESP_POP3_USR_OK_MSG "name is a valid mailbox\r\n"
#define RESP_POP3_USR_KO_MSG "never heard of mailbox name\r\n"
#define RESP_POP3_PASS_OK_MSG "maildrop locked and ready\r\n"
#define RESP_POP3_PASS_KO_LCK_MSG "unable to lock maildrop\r\n"
#define RESP_POP3_PASS_KO_WP_MSG "invalid password\r\n"
#define RESP_POP3_NOOP_MSG "\r\n"
#define RESP_POP3_LIST_NO_ID_MSG "no such message\r\n"
#define RESP_POP3_LIST_OK_MSG " %s messages (%s), scan listing follows\r\n%s\r\n"//Lista messaggi
#define RESP_POP3_LIST_ID_OK_MSG " \r\n%s\r\n"//Lista messaggi
#define RESP_POP3_STATUS_KO_MSG "invalid command in actual state\r\n"
#define RESP_POP3_DELE_OK_MSG "message %d deleted\r\n"
#define RESP_POP3_DELE_KO_MSG "no such message\r\n"
#define RESP_POP3_QUIT_MSG "dewey POP3 server signing off\r\n"
#define RESP_POP3_RSET_MSG "\r\n"
#define RESP_POP3_RTR_OK_MSG "message follows\r\n\r\n%s"
#define RESP_POP3_RTR_KO_MSG "no such message\r\n"
#define RESP_POP3_SYNTAX_KO_MSG "Syntax error, command unrecognized\r\n"


/*Comandi smtp*/


//Campi smtp
//#define FROM_SYS_STRING "FROM"
#define STR_FROM "FROM:"
#define STR_TO "TO:"
#define SUBJECT_STRING "SUBJECT:"

/*Comandi SMTP-POP3*/
#define STR_HELO "HELO"
#define STR_MAIL "MAIL"
#define STR_RCPT "RCPT"
#define STR_DATA "DATA"
#define STR_QUIT "QUIT"
#define STR_RSET "RSET"
#define STR_NOOP "NOOP"
#define STR_SEND "SEND"
#define STR_SOML "SOML"
#define STR_SAML "SAML"
#define STR_VRFY "VRFY"
#define STR_EXPN "EXPN"
#define STR_TURN "TURN"

#define STR_USER "USER"
#define STR_PASS "PASS"
#define STR_LIST "LIST"
#define STR_RETR "RETR"
#define STR_DELE "DELE"
#define STR_STAT "STAT"
#define STR_APOP "APOP"
#define STR_TOP "TOP"
#define STR_UIDL "UIDL"

#define POP3_PREFIX_OK "+OK"
#define POP3_PREFIX_ERR "-ERR"


#endif /* SMTP_H_ */



